import java.util.*;
public class Solution {


    public static int comput(String a,int i){
        Set<String> pre = new HashSet<>();
        Set<String> pos = new HashSet<>();
        for(int j=0; j<i;j++){
            pre.add(a.substring(0,j+1));
        }
        for(int j=i;j>0;j--){
            pos.add(a.substring(j,i+1));
        }
        pre.retainAll(pos);
        return pre.size();
    }

    public static int method(String s,String a){
        int[] dic = new int[a.length()];
        for(int i=0;i<a.length();i++){
            dic[i] = comput(a,i);
        }

        int max = 0;
        int i=0;
        while(i<s.length()){
            int k =i;
            int j=0;//match elements num
            int overlap = 0;
            while(k<s.length() && j<a.length()){
                if(s.charAt(k)==a.charAt(j)){
                    overlap++;
                    if(overlap>max)
                        max = overlap;
                }else {

                    overlap=0;
                }
                k++;
                j++;
            }
            if(overlap>max)
                max = overlap;
            if(overlap==0)
                i = i+1;
            else
                i =i+j-dic[j-1];
        }

        return max;

    }
    public static void main(String args[]){
//       Scanner s = new Scanner(System.in);
//       String S = s.nextLine();
//       String a = s.nextLine();
       String S = "Sit it out G";
       String a = "Sit down and shut up";
       System.out.println(method(S,a));

    }

}

//考虑最长子串不一定从头开始，可能是从其他地方开始。